package com.diandi.signature.service.impl.contract;

import com.diandi.signature.contract.FddGenerateContractService;
import com.diandi.signature.util.CreateWordUtil;
import org.springframework.stereotype.Service;

import java.net.URL;
import java.util.HashMap;
import java.util.Map;

/**
* @author mwz
* @create 2017-08-31 20:19
* @version V1.0.0
* @description description
*/
@Service
public class FddGenerateContractServiceImpl implements FddGenerateContractService {

    public static final String TEMPLATE_PATH = "/template";

    @Override
    public Map<String, String> fddGenerateContract(Map<String, Object> paramMap) {
        Map<String, String> returnMap = new HashMap<String, String>();
        try {
            URL templatePath = this.getClass().getResource(TEMPLATE_PATH);
            String path = CreateWordUtil.createWord(paramMap.get("templatePath").toString(), templatePath.getPath(), paramMap, "template", ".doc");
            returnMap.put("file", path);
            returnMap.put("responseCode", "0000");
            returnMap.put("responseMsg", "成功");
        } catch (Exception e){
            returnMap.put("responseCode", "1000");
            returnMap.put("responseMsg", "渲染模板失败");
        }
        return returnMap;
    }
}
